#ifndef ANALYSIS_H
#define ANALYSIS_H

#include <QObject>
#include <QList>
#include <QString>
#include <QHash>
#include "linevalidator.h"
#include "stat.h"
#include "analysisform.h"

/**An analysis consists of all the data and some statistics about the data. The data is fetched from different files and all the data is appended to previous data*/
class Analysis : public QObject
{
    Q_OBJECT
public:
    Analysis(QWidget* parent=NULL); // points to the AnalysisForm.
    void setDefaultLineValidator(LineValidator&);
    void doConnections(); // do a lot of connect between signals and slots with the form

    void importLogFile(QString filename);

public slots:
    void addNewLogFile(); //QWidget* parent);
    void setName(QString);
    void setStatementStatistics(); // the basic stuff
    void setDurationStatistics(); // the basic stuff

    void viewResult(); // update the analysisform with statistics

    void retrieveHistoric(QString statement);
    void retrieveFrequency(QString statement);
signals:
    void SIG_sendHistoric(Stat*);
    void SIG_sendFrequency(Stat*);
protected:
    LineValidator* m_defaultLineValidator;
    void addNewLogLine(QString); // add a line to the statistics
    void annonymizeStatement(QString& statement);
    //bool splitLine(QString& line, qreal& time, QString& statement);
    //QWidget* m_parent;

    QHash<QString,Stat*> m_statistics;
    qint64 m_totalNumberOfStatements;
private:
    QString m_name;
    AnalysisForm* m_parent;
    qreal m_totalRunningTime;
};

#endif // ANALYSIS_H
